<!DOCTYPE html>
<html lang="zh_cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>登录</title>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="__STATIC__/css/loginadmin.css" />
    <link rel="stylesheet" href="__STATIC__/common/css/font.css" />
    <script src="__STATIC__/js/jquery-1.9.1.min.js"></script>
</head>
<body class="beg-login-bg">
<div class="container login">
    <div class="content">
        <div id="large-header" class="large-header">
            <canvas id="demo-canvas"></canvas>
            <div class="main-title">
                <div class="beg-login-box">
                    <header>
                        <h1>daozicms企业后台管理系统</h1>
                    </header>
                    <div class="beg-login-main">
                        <form class="layui-form layui-form-pane">
                            <div class="layui-form-item">
                                <label class="beg-login-icon fs1">
                                    <span class="icon icon-user"></span>
                                </label>
                                <input type="text" name="username" id="username" lay-verify="required" placeholder="这里输入登录名"  class="layui-input">
                            </div>
                            <div class="layui-form-item">
                                <label class="beg-login-icon fs1">
                                    <i class="icon icon-key"></i>
                                </label>
                                <input type="password" name="password" id="password"  lay-verify="required" placeholder="这里输入密码"  class="layui-input">
                            </div>
                            {if condition="$show_verify eq 1"}
                            <div class="layui-form-item">
                                <input type="text" name="captcha" id="code" lay-verify="required" placeholder="验证码" autocomplete="off" class="layui-input">
                                <div class="captcha">
                                    <img src="{:url('Login/verify')}" alt="captcha" onclick="this.src='{:url('Login/verify')}?'+'id='+Math.random()"/>
                                </div>
                            </div>
                            {/if}
                            <div class="layui-form-item">
                                <button type="button" class="layui-btn btn-submit btn-blog"  id="login_btn" lay-submit lay-filter="login">登录</button>
                            </div>
                        </form>
                    </div>
                    <footer>
                        <p>daozicms企业后台管理系统</p>
                    </footer>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__STATIC__/js/rAF.js"></script>
<script src="__STATIC__/js/loginadmin.js"></script>
<script type="text/javascript" src="__STATIC__/layui/layui.js"></script>
<script>
    layui.use('form',function(){
        var form = layui.form,$ = layui.jquery;
        //监听提交
        form.on('submit(login)', function(data){
            loading =layer.load(1, {shade: [0.1,'#fff'] });//0.1透明度的白色背景
            $.ajax({
                type : "POST",
                dataType:"json",
                url : "{:url('login/login')}",
                data : data.field,
                success : function(res) {
                    layer.close(loading);

                    if(res.status == 200){
                        layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                            setTimeout(function () {
                                location.href = "{:url('admin/index/index')}";
                            }, 500)
                        });
                    }else{
                        layer.msg(res.msg, {icon: 2, anim: 6, time: 1000});
                        $('.captcha img').attr('src','{:url("verify")}?id='+Math.random());
                    }
                },
                error : function(e){
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });
        });
    });
</script>
</body>
</html>